package de.h_da.fbi.cg.pointcloud.adt;

import com.jme3.scene.Mesh;
import com.jme3.scene.VertexBuffer.Type;
import com.jme3.util.BufferUtils;

/**
 * @author Nicolas Gramlich
 * @since 14:56:35 - 15.11.2010
 */
public class GraphVertexMesh extends Mesh {
	// ===========================================================
	// Constants
	// ===========================================================

	// ===========================================================
	// Fields
	// ===========================================================

	// ===========================================================
	// Constructors
	// ===========================================================

	public GraphVertexMesh(final Graph pGraph) {
		this.setMode(Mode.Points);

		final VertexList vertices = pGraph.mVertices;

		final int vertexCount = vertices.size();
		final float[] vertexCoordinates = new float[vertexCount * 3];

		for(int i = 0, j = 0; i < vertexCount; i++) {
			final Vertex vertex = vertices.get(i);

			vertexCoordinates[j++] = vertex.mX;
			vertexCoordinates[j++] = vertex.mY;
			vertexCoordinates[j++] = vertex.mZ;
		}

		this.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(vertexCoordinates));
	}

	// ===========================================================
	// Getter & Setter
	// ===========================================================

	// ===========================================================
	// Methods for/from SuperClass/Interfaces
	// ===========================================================

	// ===========================================================
	// Methods
	// ===========================================================

	// ===========================================================
	// Inner and Anonymous Classes
	// ===========================================================
}
